Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

state: Fix failing code deployment in Frontier #824

Merged
merged 1 commit into from
Mar 5, 2024

Conversation

chfast
Copy link
Member

@chfast chfast commented Feb 26, 2024

In Frontier when CREATE fails to deploy the code because of the deployment cost the creation behaves as it has been successful although the created account has empty code.

Fix the CREATE instruction by returning the address of the created account instead of the null address.

The gas refund is also applied as in the case of successful code deployment. Geth agrees with this but this situation probably never happened on Mainnet.

@chfast chfast added the bug Something isn't working label Feb 26, 2024
@chfast chfast requested a review from gumb0 February 26, 2024 20:39
Copy link

codecov bot commented Feb 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.02%. Comparing base (0471449) to head (eb2cb4b).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #824      +/-   ##
==========================================
+ Coverage   97.98%   98.02%   +0.04%     
==========================================
  Files         116      116              
  Lines       11370    11457      +87     
==========================================
+ Hits        11141    11231      +90     
+ Misses        229      226       -3     
Flag Coverage Δ
blockchaintests 59.75% <ø> (ø)
statetests 62.24% <100.00%> (+0.01%) ⬆️
statetests-silkpre 24.06% <2.77%> (-0.17%) ⬇️
unittests 96.38% <100.00%> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
test/state/host.cpp 95.91% <100.00%> (+0.83%) ⬆️
test/unittests/state_transition_create_test.cpp 100.00% <100.00%> (ø)

... and 2 files with indirect coverage changes

@chfast chfast force-pushed the state/fix_frontier_code_deployment branch from 0081c26 to 83e2efc Compare February 28, 2024 11:16
const auto created = compute_create_address(To, pre.get(To).nonce);
expect.post[created].code = bytes{}; // code deployment failure creates empty account
expect.post[created].nonce = 0;
expect.post[created].storage[0x00_bytes32] = 0x01_bytes32; // storage stays
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Frontier was crazy time

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chfast chfast force-pushed the state/fix_frontier_code_deployment branch from 83e2efc to a160ae3 Compare February 29, 2024 18:41
In Frontier when CREATE fails to deploy the code because of
the deployment cost the creation behaves as it has been successful
although the created account has empty code.

Fix the CREATE instruction by returning the address of the created
account instead of the null address.

The gas refund is also applied as in the case of successful
code deployment. Geth agrees with this but this situation probably
never happened on Mainnet.
@chfast chfast force-pushed the state/fix_frontier_code_deployment branch from a160ae3 to eb2cb4b Compare March 4, 2024 16:44
@chfast chfast merged commit f8cbed0 into master Mar 5, 2024
25 checks passed
@chfast chfast deleted the state/fix_frontier_code_deployment branch March 5, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants